﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AutoMeasureV2._1
{
    /// <summary>
    /// stepUC.xaml 的交互逻辑
    /// </summary>
    public partial class stepUC : UserControl
    {
        public stepUC()
        {
            InitializeComponent();
        }

        private fileHandle handle;
        public fileHandle Handle
        {
            set
            {
                root.Children.Clear();
                handle = value;
                stepUC_1 stepUC1 = new stepUC_1();

                stepUC1.tb_title.Text = "自动化试验信息";

                stepUC1.tb_title.FontSize = 14;
                root.Children.Add(stepUC1);

                if (value.source.Count != 0)
                {

                    stepUC_1 stepUC12 = new stepUC_1();
                    stepUC_2 stepUC2 = new stepUC_2();

                    stepUC2.roots.Header = "资源";
                    stepUC12.tb_title.Text = "试验工步信息";

                    root.Children.Add(stepUC2);
                    root.Children.Add(stepUC12);
                    if (value != null)
                    {

                        stepUC_3 titleStep = new stepUC_3();
                        titleStep.Res_mesName = "资源名称";
                        titleStep.Res_mesID = "资源编号";
                        titleStep.Res_objID = "对象名称";
                        titleStep.Res_objIP = "对象地址";
                        titleStep.Res_objPort = "对象端口";
                        titleStep.Res_objDigit = "数据类型";
                        titleStep.Res_objSign = "识别码";
                        stepUC2.root.Children.Add(titleStep);
                        foreach (var item in value.source)
                        {
                            stepUC_2 stepUC22 = new stepUC_2();
                            stepUC22.roots.Header = item.UseName;
                            root.Children.Add(stepUC22);

                            stepUC_3 stepUC3 = new stepUC_3();
                            stepUC3.Res_mesName = item.UseName;
                            stepUC3.Res_mesID = item.UseID;
                            stepUC3.Res_objID = item.ObjID;
                            stepUC3.Res_objIP = item.ObjAddress;
                            stepUC3.Res_objPort = item.ObjPort;
                            stepUC3.Res_objDigit = item.ObjDigType;
                            stepUC3.Res_objSign = item.ObjSign;
                            stepUC2.root.Children.Add(stepUC3);
                            foreach (var step in item.Steps)
                            {
                                stepUC_4 stepUC4 = new stepUC_4();
                                stepUC4.ResNum ="序号："+ Convert.ToString(step.StepNum);
                                stepUC4.ResTime ="指令时间："+ Convert.ToString(step.OrderTime);
                                stepUC4.ResValue ="指令结果："+ Convert.ToString(step.TargetValue);
                                stepUC4.ResChange ="动作时间："+ Convert.ToString(step.ChangeTime);
                                stepUC22.root.Children.Add(stepUC4);
                            }
                        }
                    }
                }
            }
        }

    }
}
